﻿using System.Data.Entity.ModelConfiguration;
using yiCommerce.Core.Domain.Products;

namespace yiCommerce.Data.Mapping.Products
{
    public class ProductVariantMapping : EntityTypeConfiguration<ProductVariant>
    {

        public ProductVariantMapping()
        {
            this.ToTable("ProductVariant");
            this.HasKey(pv => pv.Id);
            this.Property(pv => pv.Name).HasMaxLength(400);
            this.Property(pv => pv.Sku).HasMaxLength(400);
            this.Property(pv => pv.Description);

            this.Property(pv => pv.Price).HasPrecision(18, 4);


            
            this.HasRequired(pv => pv.Product)
                .WithMany(p => p.ProductVariants)
                .HasForeignKey(pv => pv.ProductId);
        }
         
    }
}